package com.anmi.transfer.config;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
public class LogIPConfig extends ClassicConverter {

  private static String IP = "";

  static {
    try {
      IP = InetAddress.getLocalHost().getHostAddress();
    } catch (UnknownHostException e) {
      log.error("获取IP失败,{}", e.getMessage());
    }
  }

  @Override
  public String convert(ILoggingEvent event) {
    return IP;
  }
}
